package com.huanzhidadi.logaspect.exception;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 自定义404页面错误信息
 */
@RestController
@RequestMapping("error")
public class Error404Controller {

    /**
     * 返回Html
     * @return
     */
    @RequestMapping(value = "", produces = "text/html;charset=UTF-8")
    public String handleHtmlError() {
        return "404错误，页面不存在。";
    }

    /**
     * 返回json
     * @return
     */
    @RequestMapping(value = "", consumes = "application/json;charset=UTF-8", produces = "application/json;charset=UTF-8")
    public Map<String, Object> handleJsonError() {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 404);
        map.put("msg", "接口不存在。");
        return map;
    }
}
